﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using CiStatus.CiStatusAddIn.Logic;

namespace CiStatus.CiStatusAddIn.ViewModels
{
    public class CiStatusViewModel : ViewModelBase, ICallBack 
    {
        private readonly IRefreshPump _refreshPump;

        public CiStatusViewModel(IRefreshPump refreshPump)
        {
            _refreshPump = refreshPump;
            _refreshPump.Start(this);
        }

        public IEnumerable<ProjectViewModel> ProjectViewModelCollection
        {
            get
            {
                return _refreshPump
                    .ProjectCollection
                    .Select(project => new ProjectViewModel(project))
                    .ToList();
            }
        }

        public void Notify()
        {
            NotifyProperty(()=>ProjectViewModelCollection);
        }
    }
}